import instance from "@/utils/service/http";
import { AxiosRequestConfig } from "axios";

interface requestType<T = any> {
  code: number;
  msg: string;
  data?: T;
}

const httpReq = instance({
  baseURL: "http://124.221.181.19:8000",
});

const request = async () => {
  await httpReq.request({ url: "" });
};

const get = <T = any>(
  url: string,
  config?: AxiosRequestConfig
): Promise<requestType<T>> => {
  return httpReq.get(url, {});
};

const post = <T = any>(
  url: string,
  data: any,
  config?: AxiosRequestConfig
): Promise<requestType<T>> => {
  return httpReq.post(url, data, config);
};

const put = async (url: string) => {
  return httpReq.put(url);
};

const deleteF = (url: string, config?: AxiosRequestConfig) => {
  return httpReq.delete(url, config);
};
export { get, post, put, deleteF, request };
